// -----------------------------------------------------------------------
//  <copyright file="LoginLogConfiguration.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2025 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2025/1/9 12:41</last-date>
// -----------------------------------------------------------------------

namespace Liuliu.Fsb.Services.Identity.Infrastructure.EntityFrameworkCore.Configurations;

public class LoginLogConfiguration : EntityConfigurationBase<LoginLog>
{
    /// <summary>
    /// 重写以实现实体类型各个属性的数据库配置
    /// </summary>
    /// <param name="builder">实体类型创建器</param>
    public override void Configure(EntityTypeBuilder<LoginLog> builder)
    {
        builder.Property(m => m.Ip).HasMaxLength(50).IsRequired();
        builder.Property(m => m.UserAgent).HasMaxLength(500);
        builder.Property(m => m.Remark).HasMaxLength(500);

        builder.HasOne<User>().WithMany(n => n.LoginLogs).HasForeignKey(m => m.UserId).OnDelete(DeleteBehavior.Cascade);
    }
}
